package org.zpmis.domain.company.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zpmis.domain.company.model.Company;

import javax.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class CompanyListVo {
    /**
     * 自增ID
     */
    private Long id;

    /**
     * 企业名称
     */
    private String name;

    /**
     * 联系人
     */
    private String contactPerson;

    /**
     * 联系手机号
     */
    private String contactMobile;

    /**
     * 手机区号
     */
    private String regionCode;

    /**
     * 统一社会信用代码
     */
    private String creditCode;

    /**
     * 法定代表人
     */
    private String legalPerson;

    /**
     * 组织机构代码
     */
    private String orgCode;

    /**
     * 注册地址
     */
    private String registerAddress;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 所属行业
     */
    private String belongIndustry;

    /**
     * 公司类型
     */
    private Integer companyType;

    /**
     * 注册资本
     */
    private String registerCapital;

    /**
     * 经营范围
     */
    private String businessScope;

    /**
     * 开户银行
     */
    private String bankName;

    /**
     * 开户名
     */
    private String bankAccountName;

    /**
     * 开户账号
     */
    private String bankAccount;

    /**
     * 企业用户类型 1企业 2代理商 3代理下企业
     */
    private Integer userType;

    /**
     * 状态 0未启用1启用
     */
    private Integer status;

    /**
     * 客户来源 1官网2其他
     */
    private Integer customerSource;

    /**
     * 备注
     */
    private String remark;

    /**
     * 审核状态 0审核中 1通过2未通过
     */
    private Integer auditStatus;

    /**
     * 审核人id
     */
    private Long auditUid;

    /**
     * 审核人
     */
    private String auditPerson;

    /**
     * 审核时间
     */
    private String auditTime;

    /**
     * 附件信息
     */
    private String attachment;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String updateTime;

    /**
     * 企业code
     */
    private String companyCode;

    /**
     * 所属代理id
     */
    private Long agentId;

    public CompanyListVo(Company company) {
        this.id = company.getId();
        this.name = company.getName();
        this.contactPerson = company.getContactPerson();
        this.contactMobile = company.getContactMobile();
        this.regionCode = company.getRegionCode();
        this.creditCode = company.getCreditCode();
        this.legalPerson = company.getLegalPerson();
        this.orgCode = company.getOrgCode();
        this.registerAddress = company.getRegisterAddress();
        this.email = company.getEmail();
        this.belongIndustry = company.getBelongIndustry();
        this.companyType = company.getCompanyType();
        this.registerCapital = company.getRegisterCapital();
        this.businessScope = company.getBusinessScope();
        this.bankName = company.getBankName();
        this.bankAccountName = company.getBankAccountName();
        this.bankAccount = company.getBankAccount();
        this.userType = company.getUserType();
        this.status = company.getStatus();
        this.customerSource = company.getCustomerSource();
        this.remark = company.getRemark();
        this.auditStatus = company.getAuditStatus();
        this.auditUid = company.getAuditUid();
        this.auditPerson = company.getAuditPerson();
        this.auditTime = company.getAuditTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(company.getAuditTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.attachment = company.getAttachment();
        this.createTime =  LocalDateTime.ofInstant(Instant.ofEpochMilli(company.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.updateTime =  LocalDateTime.ofInstant(Instant.ofEpochMilli(company.getUpdateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.companyCode = company.getCompanyCode();
        this.agentId = company.getAgentId();
    }
}